class BlogPost
  include Mongoid::Document
  field :key ,:type => Integer
  field :title, :type => String 
  field :content, :type => String

  @@count = 0
  

  validates_length_of :title ,minimum: 6,maximum: 17,wrong_length: "sara"
  validates_length_of :content,maximum: 300
  before_create :generate_id


  
  def generate_id
    @@count += 1
    self.key = @@count
  end
end


